/*
 * CPlayerStatsRenderer.java
 *
 * Copyright (c) 2009 Giles Millward (Manigra). All rights reserved.
 *
 * This file is part of JRogueDPS.
 *
 * JRogueDPS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * JRogueDPS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with JRogueDPS.  If not, see <http://www.gnu.org/licenses/>.
 */

package jroguedps;

import java.awt.Color;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

/**
 *
 * @author Mani
 */
public class CPlayerStatsRenderer extends JLabel
                           implements TableCellRenderer {
    boolean isBordered = true;

    public CPlayerStatsRenderer() {
        this.isBordered = false;
        setOpaque(true);
    }

    public Component getTableCellRendererComponent(
                            JTable table, Object p_object,
                            boolean isSelected, boolean hasFocus,
                            int row, int column) {
        if (column == 0)
        {
            this.setText((String) p_object);
            this.setBackground(Color.WHITE);
            this.setToolTipText("");
            return this;
        }

        if (p_object == null)
        {
            this.setText("");
            this.setBackground(Color.WHITE);
            this.setToolTipText("");
            return this;
        }

        CPlayerTableStat l_tableStat = (CPlayerTableStat) p_object;
        this.setText(l_tableStat.m_value);
        this.setBackground(l_tableStat.m_color);
        if (l_tableStat.m_tooltip != null)
        {
            this.setToolTipText(l_tableStat.m_tooltip);
        }
        else
        {
            this.setToolTipText("");
        }

        return this;
    }
}